package com.webank.tikv.kvproto;

import static io.grpc.MethodDescriptor.generateFullMethodName;

/**
 * <pre>
 * Key/value store API for TiKV.
 * </pre>
 */
@javax.annotation.Generated(
    value = "by gRPC proto compiler (version 1.68.1)",
    comments = "Source: tikvpb.proto")
@io.grpc.stub.annotations.GrpcGenerated
public final class TikvGrpc {

  private TikvGrpc() {}

  public static final java.lang.String SERVICE_NAME = "tikvpb.Tikv";

  // Static method descriptors that strictly reflect the proto.
  private static volatile io.grpc.MethodDescriptor<com.webank.tikv.kvproto.Kvrpcpb.RedisRequest,
      com.webank.tikv.kvproto.Kvrpcpb.RedisResponse> getRedisExecMethod;

  @io.grpc.stub.annotations.RpcMethod(
      fullMethodName = SERVICE_NAME + '/' + "RedisExec",
      requestType = com.webank.tikv.kvproto.Kvrpcpb.RedisRequest.class,
      responseType = com.webank.tikv.kvproto.Kvrpcpb.RedisResponse.class,
      methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
  public static io.grpc.MethodDescriptor<com.webank.tikv.kvproto.Kvrpcpb.RedisRequest,
      com.webank.tikv.kvproto.Kvrpcpb.RedisResponse> getRedisExecMethod() {
    io.grpc.MethodDescriptor<com.webank.tikv.kvproto.Kvrpcpb.RedisRequest, com.webank.tikv.kvproto.Kvrpcpb.RedisResponse> getRedisExecMethod;
    if ((getRedisExecMethod = TikvGrpc.getRedisExecMethod) == null) {
      synchronized (TikvGrpc.class) {
        if ((getRedisExecMethod = TikvGrpc.getRedisExecMethod) == null) {
          TikvGrpc.getRedisExecMethod = getRedisExecMethod =
              io.grpc.MethodDescriptor.<com.webank.tikv.kvproto.Kvrpcpb.RedisRequest, com.webank.tikv.kvproto.Kvrpcpb.RedisResponse>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
              .setFullMethodName(generateFullMethodName(SERVICE_NAME, "RedisExec"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  com.webank.tikv.kvproto.Kvrpcpb.RedisRequest.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  com.webank.tikv.kvproto.Kvrpcpb.RedisResponse.getDefaultInstance()))
              .setSchemaDescriptor(new TikvMethodDescriptorSupplier("RedisExec"))
              .build();
        }
      }
    }
    return getRedisExecMethod;
  }

  /**
   * Creates a new async stub that supports all call types for the service
   */
  public static TikvStub newStub(io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<TikvStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<TikvStub>() {
        @java.lang.Override
        public TikvStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new TikvStub(channel, callOptions);
        }
      };
    return TikvStub.newStub(factory, channel);
  }

  /**
   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
   */
  public static TikvBlockingStub newBlockingStub(
      io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<TikvBlockingStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<TikvBlockingStub>() {
        @java.lang.Override
        public TikvBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new TikvBlockingStub(channel, callOptions);
        }
      };
    return TikvBlockingStub.newStub(factory, channel);
  }

  /**
   * Creates a new ListenableFuture-style stub that supports unary calls on the service
   */
  public static TikvFutureStub newFutureStub(
      io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<TikvFutureStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<TikvFutureStub>() {
        @java.lang.Override
        public TikvFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new TikvFutureStub(channel, callOptions);
        }
      };
    return TikvFutureStub.newStub(factory, channel);
  }

  /**
   * <pre>
   * Key/value store API for TiKV.
   * </pre>
   */
  public interface AsyncService {

    /**
     */
    default void redisExec(com.webank.tikv.kvproto.Kvrpcpb.RedisRequest request,
        io.grpc.stub.StreamObserver<com.webank.tikv.kvproto.Kvrpcpb.RedisResponse> responseObserver) {
      io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getRedisExecMethod(), responseObserver);
    }
  }

  /**
   * Base class for the server implementation of the service Tikv.
   * <pre>
   * Key/value store API for TiKV.
   * </pre>
   */
  public static abstract class TikvImplBase
      implements io.grpc.BindableService, AsyncService {

    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
      return TikvGrpc.bindService(this);
    }
  }

  /**
   * A stub to allow clients to do asynchronous rpc calls to service Tikv.
   * <pre>
   * Key/value store API for TiKV.
   * </pre>
   */
  public static final class TikvStub
      extends io.grpc.stub.AbstractAsyncStub<TikvStub> {
    private TikvStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @java.lang.Override
    protected TikvStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new TikvStub(channel, callOptions);
    }

    /**
     */
    public void redisExec(com.webank.tikv.kvproto.Kvrpcpb.RedisRequest request,
        io.grpc.stub.StreamObserver<com.webank.tikv.kvproto.Kvrpcpb.RedisResponse> responseObserver) {
      io.grpc.stub.ClientCalls.asyncUnaryCall(
          getChannel().newCall(getRedisExecMethod(), getCallOptions()), request, responseObserver);
    }
  }

  /**
   * A stub to allow clients to do synchronous rpc calls to service Tikv.
   * <pre>
   * Key/value store API for TiKV.
   * </pre>
   */
  public static final class TikvBlockingStub
      extends io.grpc.stub.AbstractBlockingStub<TikvBlockingStub> {
    private TikvBlockingStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @java.lang.Override
    protected TikvBlockingStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new TikvBlockingStub(channel, callOptions);
    }

    /**
     */
    public com.webank.tikv.kvproto.Kvrpcpb.RedisResponse redisExec(com.webank.tikv.kvproto.Kvrpcpb.RedisRequest request) {
      return io.grpc.stub.ClientCalls.blockingUnaryCall(
          getChannel(), getRedisExecMethod(), getCallOptions(), request);
    }
  }

  /**
   * A stub to allow clients to do ListenableFuture-style rpc calls to service Tikv.
   * <pre>
   * Key/value store API for TiKV.
   * </pre>
   */
  public static final class TikvFutureStub
      extends io.grpc.stub.AbstractFutureStub<TikvFutureStub> {
    private TikvFutureStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @java.lang.Override
    protected TikvFutureStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new TikvFutureStub(channel, callOptions);
    }

    /**
     */
    public com.google.common.util.concurrent.ListenableFuture<com.webank.tikv.kvproto.Kvrpcpb.RedisResponse> redisExec(
        com.webank.tikv.kvproto.Kvrpcpb.RedisRequest request) {
      return io.grpc.stub.ClientCalls.futureUnaryCall(
          getChannel().newCall(getRedisExecMethod(), getCallOptions()), request);
    }
  }

  private static final int METHODID_REDIS_EXEC = 0;

  private static final class MethodHandlers<Req, Resp> implements
      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
    private final AsyncService serviceImpl;
    private final int methodId;

    MethodHandlers(AsyncService serviceImpl, int methodId) {
      this.serviceImpl = serviceImpl;
      this.methodId = methodId;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("unchecked")
    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_REDIS_EXEC:
          serviceImpl.redisExec((com.webank.tikv.kvproto.Kvrpcpb.RedisRequest) request,
              (io.grpc.stub.StreamObserver<com.webank.tikv.kvproto.Kvrpcpb.RedisResponse>) responseObserver);
          break;
        default:
          throw new AssertionError();
      }
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("unchecked")
    public io.grpc.stub.StreamObserver<Req> invoke(
        io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        default:
          throw new AssertionError();
      }
    }
  }

  public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) {
    return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
        .addMethod(
          getRedisExecMethod(),
          io.grpc.stub.ServerCalls.asyncUnaryCall(
            new MethodHandlers<
              com.webank.tikv.kvproto.Kvrpcpb.RedisRequest,
              com.webank.tikv.kvproto.Kvrpcpb.RedisResponse>(
                service, METHODID_REDIS_EXEC)))
        .build();
  }

  private static abstract class TikvBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
    TikvBaseDescriptorSupplier() {}

    @java.lang.Override
    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
      return com.webank.tikv.kvproto.Tikvpb.getDescriptor();
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
      return getFileDescriptor().findServiceByName("Tikv");
    }
  }

  private static final class TikvFileDescriptorSupplier
      extends TikvBaseDescriptorSupplier {
    TikvFileDescriptorSupplier() {}
  }

  private static final class TikvMethodDescriptorSupplier
      extends TikvBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
    private final java.lang.String methodName;

    TikvMethodDescriptorSupplier(java.lang.String methodName) {
      this.methodName = methodName;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
      return getServiceDescriptor().findMethodByName(methodName);
    }
  }

  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;

  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
    io.grpc.ServiceDescriptor result = serviceDescriptor;
    if (result == null) {
      synchronized (TikvGrpc.class) {
        result = serviceDescriptor;
        if (result == null) {
          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
              .setSchemaDescriptor(new TikvFileDescriptorSupplier())
              .addMethod(getRedisExecMethod())
              .build();
        }
      }
    }
    return result;
  }
}
